package vn.elca.training.important_classes_excercise;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class Question8 {
	public static void main(String[] args) {
		String carBrand = "BMW Kia-Forte Toyota-Camry Lexus Honda-Civic Audi";
		String[] carArray = carBrand.split(" ");
		Iterator<String> it;
		String st;
		List<String> carList = Arrays.asList(carArray);
		System.out.println("First way : get(i)");
		for (int i = 0; i < carList.size(); i++) {
			System.out.print("[" + carList.get(i) + "] ");
		}
		System.out.println("\nSecond way : Iterator");
		it = carList.iterator();
		while (it.hasNext()) {
			st = it.next();
			System.out.print("[" + st + "] ");
		}
		System.out.println("\nThird way : for-each ");
		for (String s: carList) {
			System.out.print("[" + s+ "] ");
		}
		
	}

}
